//SPDX-FileCopyrightText: Copyright 2025-2025 深圳市同心圆网络有限公司
//SPDX-License-Identifier: GPL-3.0-only

import { invoke } from "@tauri-apps/api/core";

export type ServerInfo = {
    name: string,
    system: boolean;
    addr: string;
    default_server: boolean;
};

export type ListServerResult = {
    server_list: ServerInfo[];
};

export async function list_server(): Promise<ListServerResult> {
    return invoke<ListServerResult>('client_cfg_list_server', {});
}

export async function save_server_list(serverList: ServerInfo[]): Promise<void> {
    return invoke<void>('client_cfg_save_server_list', {
        serverList: serverList,
    });
}